	********************************************************************************
** ReplicationPeerOpinion.do ***************************************************
** 
** Ecker-Ehrhardt, Matthias, Lisa Dellmuth, and Jonas Tallberg. 2025. 
** Peer Opinion and the Legitimacy of International Organizations.
** Review of International Organization, forthcoming
**
** Input: ReplicationPeerOpinion.dta
**
** Machine: Macbook Pro 16, Sequoia 15.4.1
** Program Version: Stata 17.0
**
********************************************************************************
********************************************************************************

* ssc install estout
* ssc install blindschemes
* ssc install coefplot

mkdir Tables
mkdir Figures

********************************************************************************
********************************************************************************
** Main Analysis  // Appendix C ************************************************
********************************************************************************
********************************************************************************


********************************************************************************
* H1/H2 ************************************************************************
********************************************************************************


** Figure 2 / Table C1 *********************************************************


clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all

* E1 *********

reg Q18_1 E1_F12_p E1_F12_n GE US, robust

estimates store E1_F12
coefplot E1*, keep(E1_*) title("#1 Participants/WHO") /// 
	legend(off) name(E1) vert  /// 
	ylabel(-2(.5)2) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

* E2 *********

reg Q20_1 E2_F12_p E2_F12_n GE US, robust

estimates store E2_F12
coefplot E2*, keep(E2_*) title("#2 Polls/IMF") /// 
	legend(off) name(E2) vert /// 
	ylabel(-2(.5)2) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate)) 
* E3 *********

reg Q22_1 E3_F12_p E3_F12_n GE US, robust

estimates store E3_F12
coefplot E3*, keep(E3_*) title("#3 SocialMedia/UN") /// 
	legend(off) name(E3) vert /// 
	ylabel(-2(.5)2) yline(0, lpattern(shortdash) lcolor(gray))  /// 
	xlabel(,  labsize(moderate))

**

esttab * using Tables/TabC1.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace
	  
gr combine E1 E2 E3, col(3) iscale(1)

graph export Figures/Fig2.jpg, replace



** Figure/Table C10 w/ weights *************************************************


clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all

svyset  [pweight=RIMWEIGHT2] 

* E1 *********

svy: reg Q18_1 E1_F12_p E1_F12_n GE US
estimates store E1_F12
coefplot E1*, keep(E1_*) title("#1 Participants/WHO") /// 
	legend(off) name(E1) vert /// 
	ylabel(-2(.5)2) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

* E2 *********

svy: reg Q20_1 E2_F12_p E2_F12_n GE US
estimates store E2_F12
coefplot E2*, keep(E2_*) title("#2 Polls/IMF") /// 
	legend(off) name(E2) vert /// 
	ylabel(-2(.5)2) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

* E3 *********

svy: reg Q22_1 E3_F12_p E3_F12_n GE US
estimates store E3_F12
coefplot E3*, keep(E3_*) title("#3 SocialMedia/UN") /// 
	legend(off) name(E3) vert /// 
	ylabel(-2(.5)2) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

**

esttab * using Tables/TabC10.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace
	  
gr combine E1 E2 E3, col(3) iscale(1)
graph export Figures/FigC10.jpg, replace  // not in the Appendix




** Figure/Table C11 w/ controls *************************************************


clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all

vl create CONTROL = (confgov finsathousehold polsatisfaction /// 
	feelcountry feelworld /// 
	age male eduRecode GE US)

* E1 *********

reg Q18_1 E1_F12_p E1_F12_n $CONTROL i.pos_e1, robust
estimates store E1_F12
coefplot E1*, keep(E1_*) title("#1 Participants/WHO") /// 
	legend(off) name(E1) vert /// 
	ylabel(-2(.5)2) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

* E2 *********

reg Q20_1 E2_F12_p E2_F12_n $CONTROL i.pos_e2, robust
estimates store E2_F12
coefplot E2*, keep(E2_*) title("#2 Polls/IMF") /// 
	legend(off) name(E2) vert /// 
	ylabel(-2(.5)2) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

* E3 *********

reg Q22_1 E3_F12_p E3_F12_n $CONTROL i.pos_e3, robust
estimates store E3_F12
coefplot E3*, keep(E3_*) title("#3 SocialMedia/UN") /// 
	legend(off) name(E3) vert /// 
	ylabel(-2(.5)2) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

**

esttab * using Tables/TabC11.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace
	  
gr combine E1 E2 E3, col(3) iscale(1)
graph export Figures/FigC11.jpg, replace   // not in the Appendix



** Figure/Table C12 only those who mastered the manipulation checks ************


clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all

* E1 *********

reg Q18_1 E1_F12_p E1_F12_n GE US if mcheck1==1, robust
estimates store E1_F12
coefplot E1*, keep(E1_*) title("#1 Participants/WHO") /// 
	legend(off) name(E1) vert /// 
	ylabel(-1.5(.5)1.5) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

* E2 *********

reg Q20_1 E2_F12_p E2_F12_n GE US if mcheck2==1, robust
estimates store E2_F12
coefplot E2*, keep(E2_*) title("#2 Polls/IMF") /// 
	legend(off) name(E2) vert /// 
	ylabel(-1.5(.5)1.5) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

* E3 *********

reg Q22_1 E3_F12_p E3_F12_n GE US if mcheck3==1, robust
estimates store E3_F12
coefplot E3*, keep(E3_*) title("#3 SocialMedia/UN") /// 
	legend(off) name(E3) vert /// 
	ylabel(-1.5(.5)1.5) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

**

esttab * using Tables/TabC12.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace
	  
gr combine E1 E2 E3, col(3) iscale(1)
graph export Figures/FigC12.jpg, replace   // not in the Appendix



** Figure/Table C13 country-specific *******************************************


clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all

* E1 *********

reg Q18_1 E1_F12_p E1_F12_n if BR==1, robust
estimates store E1_F12_BR

reg Q18_1 E1_F12_p E1_F12_n if GE==1, robust
estimates store E1_F12_GE

reg Q18_1 E1_F12_p E1_F12_n if US==1, robust
estimates store E1_F12_US

* E2 *********

reg Q20_1 E2_F12_p E2_F12_n if BR==1, robust
estimates store E2_F12_BR

reg Q20_1 E2_F12_p E2_F12_n if GE==1, robust
estimates store E2_F12_GE

reg Q20_1 E2_F12_p E2_F12_n if US==1, robust
estimates store E2_F12_US

* E3 *********

reg Q22_1 E3_F12_p E3_F12_n if BR==1, robust
estimates store E3_F12_BR

reg Q22_1 E3_F12_p E3_F12_n if GE==1, robust
estimates store E3_F12_GE

reg Q22_1 E3_F12_p E3_F12_n if US==1, robust
estimates store E3_F12_US

**

esttab E1* E2* E3* using Tables/TabC13.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace
	  

	  
	  
********************************************************************************
* H3 ***************************************************************************
********************************************************************************

	  
** Figure 3 / Table C2 *********************************************************


clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all


* E1 *********

reg Q18_1 E1_F12_p2 E1_F12_p1 E1_F12_n1 E1_F12_n2 GE US, robust
estimates store E1

coefplot E1*, keep(E1_*) title("#1 Participants/WHO") /// 
	legend(off) name(E1) vert /// 
	ylabel(-2(.5)2) yline(0, lpattern(shortdash) lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

* E2 *********

reg Q20_1 E2_F12_p2 E2_F12_p1 E2_F12_n1 E2_F12_n2 GE US, robust
estimates store E2

coefplot E2*, keep(E2_*) title("#2 Polls/IMF") /// 
	legend(off) name(E2) vert /// 
	ylabel(-2(.5)2) yline(0, lpattern(shortdash) lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

* E3 *********

reg Q22_1 E3_F12_p2 E3_F12_p1 E3_F12_n1 E3_F12_n2 GE US, robust
estimates store E3

coefplot E3*, keep(E3_*) title("#3 SocialMedia/UN") /// 
	legend(off) name(E3) vert /// 
	ylabel(-2(.5)2) yline(0, lpattern(shortdash) lcolor(gray)) /// 
	xlabel(,  labsize(moderate))

**
esttab * using Tables/TabC2.rtf, se(%9.3f) b(%9.3f) ////// 
	nobase label replace

gr combine E1 E2 E3, col(3) iscale(1)
graph export Figures/Fig3.jpg, replace



* Table C3  w/ contrast coding, "weak" as baseline to test diff strong vs. weak


clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all

reg Q18_1 E1_F12_p2 E1_F12_p1b E1_F12_n1b E1_F12_n2 GE US, robust
estimates store E1

reg Q20_1 E2_F12_p2 E2_F12_p1b E2_F12_n1b E2_F12_n2 GE US, robust
estimates store E2

reg Q22_1 E3_F12_p2 E3_F12_p1b E3_F12_n1b E3_F12_n2 GE US, robust
estimates store E3

esttab * using Tables/TabC3.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace


	  
* Table C4: Levels of confidence as observed in ("pure") control groups


clear
use PeerOpinionData.dta
set scheme plotplain

* code confidence variables

gen confWHO = Q18_1 if cellExperiment1==13
recode confWHO 1/5=0 6/10=1
tab confWHO

gen confIMF = Q20_1 if cellExperiment2==13
recode confIMF 1/5=0 6/10=1
tab confIMF Q20_1

gen confUNO = Q22_1 if cellExperiment3==13
recode confUNO 1/5=0 6/10=1
tab confUNO

label define m_conf 0 "Little confidence" 1 "Much confidence", replace
la val conf* know m_conf

asdoc tab1 confWHO confIMF confUNO, save(Tables/TabC4.rtf) replace 





** Table C14 Effect of degree of peer consensus (H3) across country samples ****

clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all


* E1 *********

reg Q18_1 E1_F12_p2 E1_F12_p1 E1_F12_n1 E1_F12_n2 if BR==1, robust
estimates store E1_BR

reg Q18_1 E1_F12_p2 E1_F12_p1 E1_F12_n1 E1_F12_n2 if GE==1, robust
estimates store E1_GE

reg Q18_1 E1_F12_p2 E1_F12_p1 E1_F12_n1 E1_F12_n2 if US==1, robust
estimates store E1_US

* E2 *********

reg Q20_1 E2_F12_p2 E2_F12_p1 E2_F12_n1 E2_F12_n2 if BR==1, robust
estimates store E2_BR

reg Q20_1 E2_F12_p2 E2_F12_p1 E2_F12_n1 E2_F12_n2 if GE==1, robust
estimates store E2_GE

reg Q20_1 E2_F12_p2 E2_F12_p1 E2_F12_n1 E2_F12_n2 if US==1, robust
estimates store E2_US

* E3 *********

reg Q22_1 E3_F12_p2 E3_F12_p1 E3_F12_n1 E3_F12_n2 if BR==1, robust
estimates store E3_BR

reg Q22_1 E3_F12_p2 E3_F12_p1 E3_F12_n1 E3_F12_n2 if GE==1, robust
estimates store E3_GE

reg Q22_1 E3_F12_p2 E3_F12_p1 E3_F12_n1 E3_F12_n2 if US==1, robust
estimates store E3_US


**
esttab E1* E2* E3* using Tables/TabC14.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001)  ///
	  nobase label replace





	  
********************************************************************************
** H4 **************************************************************************
********************************************************************************


* Table C5 Regression results on ATE of elite cues *****************************


clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all

* E1 *********

reg Q18_1 E1_F3_p E1_F3_n GE US, robust
estimates store E1_F3
coefplot E1*, keep(E1_*) title("#1 Participants/WHO") /// 
	legend(off) name(E1) vert /// 
	ylabel(-.5(.1).5) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))


* E2 *********

reg Q20_1 E2_F3_p E2_F3_n GE US, robust
estimates store E2_F3
coefplot E2*, keep(E2_*) title("#2 Polls/IMF") /// 
	legend(off) name(E2) vert /// 
	ylabel(-.5(.1).5) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))


* E3 *********

reg Q22_1 E3_F3_p E3_F3_n GE US, robust
estimates store E3_F3
coefplot E3*, keep(E3_*) title("#3 SocialMedia/UN") /// 
	legend(off) name(E3) vert /// 
	ylabel(-.5(.1).5) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(moderate))


**

esttab * using Tables/TabC5.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace
	  
gr combine E1 E2 E3, col(3) iscale(1)
graph export Figures/FigC5.jpg, replace	  // not in the Appendix




** Figure 4 / Table C6 *********************************************************


clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all

* E1 *********

reg Q18_1 b1.E1_F12##E1_F3 GE US, robust   // b1. => control group as baseline
estimates store E1

margins, dydx(E1_F12) at(E1_F3=(0(1)1))
marginsplot, recast(scatter)  ///
	ytitle("") xtitle("") xsc(r(-0.5 1.5)) ///
	legend(order(4 "peers +/++" 3 "peers -/--") pos(12) ring(0) r(3) ///
	region(lstyle(none))) name(E1) title("#1 Participants/WHO") /// 
	ylabel(-1.5(.5)1.5) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(small))
	

* E2 *********

reg Q20_1 b1.E2_F12##E2_F3 GE US, robust
estimates store E2

margins, dydx(E2_F12) at(E2_F3=(0(1)1))
marginsplot, recast(scatter)   ///
	ytitle("") xtitle("") xsc(r(-0.5 1.5)) ///
	legend(order(4 "peers +/++" 3 "peers -/--") pos(12) ring(0) r(3) ///
	region(lstyle(none))) name(E2) title("#2 Polls/IMF") /// 
	ylabel(-1.5(.5)1.5) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(small))

	
* E3 *********

reg Q22_1 b1.E3_F12##E3_F3 GE US, robust
estimates store E3

margins, dydx(E3_F12) at(E3_F3=(0(1)1))
marginsplot, recast(scatter)  ///
	ytitle("") xtitle("") xsc(r(-0.5 1.5)) ///
	legend(order(4 "peers +/++" 3 "peers -/--") pos(12) ring(0) r(3) ///
	region(lstyle(none))) name(E3) title("#3 SocialMedia/UN") /// 
	ylabel(-1.5(.5)1.5) yline(0, lpattern(shortdash)lcolor(gray)) /// 
	xlabel(,  labsize(small))
	
**

esttab * using Tables/TabC6.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace

gr combine E1 E2 E3, col(3) iscale(1)
graph export Figures/Fig4.jpg, replace	 




** Table C7 Effect of elite cues (H4) for government supporters only ***********


clear
use PeerOpinionData.dta

estimates drop _all
graph drop _all

reg Q18_1 b1.E1_F12##E1_F3 GE US if confgov>2, robust  //mean = ??
estimates store E1

reg Q20_1 b1.E2_F12##E2_F3 GE US  if confgov>2, robust
estimates store E2

reg Q22_1 b1.E3_F12##E3_F3 GE US  if confgov>2, robust 
estimates store E3

esttab * using Tables/TabC7.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) ///
	  nobase label replace



** Table C15 Effect of elite cues (H4) across country samples ******************


clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all

* E1 *********

reg Q18_1 b1.E1_F12##E1_F3   if BR==1, robust
estimates store E1_BR 
 
reg Q18_1 b1.E1_F12##E1_F3   if GE==1, robust
estimates store E1_GE 
 
reg Q18_1 b1.E1_F12##E1_F3   if US==1, robust
estimates store E1_US 
 
* E2 ********* 
 
reg Q20_1 b1.E2_F12##E2_F3   if  BR==1, robust
estimates store E2_BR 
 
reg Q20_1 b1.E2_F12##E2_F3   if  GE==1, robust
estimates store E2_GE 
 
reg Q20_1 b1.E2_F12##E2_F3   if  US==1, robust
estimates store E2_US 
	 
* E3 ********* 
 
reg Q22_1 b1.E3_F12##E3_F3   if  BR==1, robust
estimates store E3_BR 
 
reg Q22_1 b1.E3_F12##E3_F3   if  GE==1, robust
estimates store E3_GE 
 
reg Q22_1 b1.E3_F12##E3_F3   if  US==1, robust
estimates store E3_US

**

esttab E1* E2* E3* using Tables/TabC15.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace



********************************************************************************
** H5, Education ***************************************************************
********************************************************************************



** Figure 5 / Table C8 *********************************************************


clear
use PeerOpinionData.dta
set scheme plotplain
	
estimates drop _all
graph drop _all

* E1 *********

reg Q18_1 b1.E1_F12##i.lowedu GE US, robust
estimates store E1

margins, dydx(E1_F12) at(lowedu=(0(1)1))
marginsplot, recast(scatter) ylabel(-2(.5)2.5) /// 
	yline(0, lpattern(shortdash)lcolor(gray))  ///
	ytitle("") xtitle("Education", size(small)) xsc(r(-0.5 1.5)) ///
	xlabel(0 "low" 1 "high") ///
	legend(order(4 "peers +/++" 3 "peers -/--") pos(12) ring(0) r(3) ///
	region(lstyle(none))) name(E1) title("#1 Participants/WHO") 
	
* E2 *********

reg Q20_1 b1.E2_F12##i.lowedu GE US, robust
estimates store E2

margins, dydx(E2_F12) at(lowedu=(0(1)1))
marginsplot, recast(scatter)  ylabel(-2(.5)2.5) /// 
	yline(0, lpattern(shortdash)lcolor(gray))  ///
	ytitle("") xtitle("Education", size(small)) xsc(r(-0.5 1.5)) ///
	xlabel(0 "low" 1 "high") ///
	legend(order(4 "peers +/++" 3 "peers -/--") pos(12) ring(0) r(3) ///
	region(lstyle(none))) name(E2) title("#2 Polls/IMF")

* E3 *********

reg Q22_1 b1.E3_F12##i.lowedu GE US, robust
estimates store E3

margins, dydx(E3_F12) at(lowedu=(0(1)1))
marginsplot, recast(scatter)  ylabel(-2(.5)2.5) /// 
	yline(0, lpattern(shortdash)lcolor(gray))  ///
	ytitle("") xtitle("Education", size(small)) xsc(r(-0.5 1.5)) ///
	xlabel(0 "low" 1 "high") ///
	legend(order(4 "peers +/++" 3 "peers -/--") pos(12) ring(0) r(3) ///
	region(lstyle(none))) name(E3) title("#3 SocialMedia/UN")
	
	
**

esttab * using Tables/TabC8.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace

gr combine E1 E2 E3, col(3) iscale(1)
graph export Figures/Fig5.jpg, replace	 	 



** Table C16 by country ********************************************************


clear
use PeerOpinionData.dta
set scheme plotplain
	
estimates drop _all
graph drop _all

reg Q18_1 b1.E1_F12##i.lowedu if BR==1, robust
estimates store E1_BR

reg Q18_1 b1.E1_F12##i.lowedu if GE==1, robust
estimates store E1_GE

reg Q18_1 b1.E1_F12##i.lowedu if US==1, robust
estimates store E1_US


reg Q20_1 b1.E2_F12##i.lowedu if BR==1, robust
estimates store E2_BR

reg Q20_1 b1.E2_F12##i.lowedu if GE==1, robust
estimates store E2_GE

reg Q20_1 b1.E2_F12##i.lowedu if US==1, robust
estimates store E2_US


reg Q22_1 b1.E3_F12##i.lowedu if BR==1, robust
estimates store E3_BR

reg Q22_1 b1.E3_F12##i.lowedu if GE==1, robust
estimates store E3_GE

reg Q22_1 b1.E3_F12##i.lowedu if US==1, robust
estimates store E3_US
	
**

esttab E1* E2* E3* using Tables/TabC16.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace


********************************************************************************
** H5, Knowledge ***************************************************************
********************************************************************************


** Figure 6 / Table C9 *********************************************************


clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all

* E1 *********

reg Q18_1 b1.E1_F12##i.know GE US, robust
estimates store E1

margins, dydx(E1_F12) at(know=(0(1)1))
marginsplot, recast(scatter) ylabel(-2(.5)2) /// 
	yline(0, lpattern(shortdash)lcolor(gray)) ///
	ytitle("") xtitle("Knowledge", size(small)) xsc(r(-0.5 1.5)) ///
	xlabel(0 "low" 1 "high") ///
	legend(order(4 "peers +/++" 3 "peers -/--") pos(12) ring(0) r(3) ///
	region(lstyle(none))) name(E1) title("#1 Participants/WHO") 
	

* E2 *********

reg Q20_1 b1.E2_F12##i.know GE US, robust
estimates store E2

margins, dydx(E2_F12) at(know=(0(1)1))
marginsplot, recast(scatter) ylabel(-2(.5)2) /// 
	yline(0, lpattern(shortdash)lcolor(gray)) ///
	ytitle("") xtitle("Knowledge", size(small)) xsc(r(-0.5 1.5)) ///
	xlabel(0 "low" 1 "high") ///
	legend(order(4 "peers +/++" 3 "peers -/--") pos(12) ring(0) r(3) ///
	region(lstyle(none))) name(E2) title("#2 Polls/IMF")

	
* E3 *********

reg Q22_1 b1.E3_F12##i.know GE US, robust
estimates store E3

margins, dydx(E3_F12) at(know=(0(1)1))
marginsplot, recast(scatter) ylabel(-2(.5)2) /// 
	yline(0, lpattern(shortdash)lcolor(gray)) ///
	ytitle("") xtitle("Knowledge", size(small)) xsc(r(-0.5 1.5)) ///
	xlabel(0 "low" 1 "high") ///
	legend(order(4 "peers +/++" 3 "peers -/--") pos(12) ring(0) r(3) ///
	region(lstyle(none))) name(E3) title("#3 SocialMedia/UN")
	
**

esttab * using Tables/TabC9.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace

gr combine E1 E2 E3, col(3) iscale(1)    
graph export Figures/Fig6.jpg, replace



** Table C17 by country ********************************************************


clear
use PeerOpinionData.dta
set scheme plotplain

estimates drop _all
graph drop _all


reg Q18_1 b1.E1_F12##i.know if BR==1, robust
estimates store E1_BR

reg Q20_1 b1.E2_F12##i.know if BR==1, robust
estimates store E2_BR

reg Q22_1 b1.E3_F12##i.know if BR==1, robust
estimates store E3_BR
	

reg Q18_1 b1.E1_F12##i.know if GE==1, robust
estimates store E1_GE

reg Q20_1 b1.E2_F12##i.know if GE==1, robust
estimates store E2_GE

reg Q22_1 b1.E3_F12##i.know if GE==1, robust
estimates store E3_GE
	

reg Q18_1 b1.E1_F12##i.know if US==1, robust
estimates store E1_US

reg Q20_1 b1.E2_F12##i.know if US==1, robust
estimates store E2_US

reg Q22_1 b1.E3_F12##i.know if US==1, robust
estimates store E3_US
	
esttab E1* E2* E3* using Tables/TabC17.rtf, se(%9.3f) b(%9.3f) ///
      scalars(r2 N) varwidth(16) starlevels(* 0.05 ** 0.01 *** 0.001) /// 
	  nobase label replace


	  
	  
********************************************************************************
********************************************************************************
* Appendix B (Sample Properties) ***********************************************
********************************************************************************
********************************************************************************


clear
use PeerOpinionData.dta


* Table B1 Sample size by country **********************************************

asdoc tab Country, save(Tables/TabB1.rtf) replace 


* Table B2a: Age by country (sample) *******************************************

asdoc tab dAge Country, col nof save(Tables/TabB2a.rtf) replace 


* Table B3a: Gender by country (sample) ****************************************

asdoc tab S2 Country, col nof save(Tables/TabB3a.rtf) replace 


* Table B4a Education by country (sample) **************************************

asdoc tab eduRecode Country, col nof save(Tables/TabB4a.rtf) replace 


* Table B5 Descriptives ********************************************************

estpost tabstat ///
	Q18_1 Q20_1 Q22_1 confgov finsathousehold polsatisfaction feelcountry /// 
	feelworld age male eduRecode know pos_e1 pos_e2 pos_e3 mcheck1 mcheck2 /// 
	mcheck3, columns(statistics) statistics(count mean min max sd)

esttab using Tables/TabB5.rtf, cells  /// 
("count(fmt(%9.0f)) min(fmt(%9.0f)) sd(fmt(%9.3f)) max(fmt(%9.0f)) mean(fmt(%9.3f))") /// 
	label varwidth(30) noobs replace


* Table B6 Assignment across treatment groups (pooled dataset) *****************

asdoc tab F12experiment1Recode F3experiment1Recode, /// 
  save(Tables/TabB6a.rtf) replace 
asdoc tab F12experiment2Recode F3experiment2Recode, /// 
  save(Tables/TabB6b.rtf) replace 
asdoc tab F12experiment3Recode F3experiment3Recode, /// 
  save(Tables/TabB6c.rtf) replace 


* Table B7 Sample Balance across treatment groups ******************************

estimates drop _all
eststo clear

foreach c in  1 2 3 {
	
reg 			age 		i.F12experiment`c'Recode
est sto 	E`c'_age
testparm 		age 		i.F12experiment`c'Recode
estadd scalar p_value = r(p)

reg 			male		i.F12experiment`c'Recode
est sto 	E`c'_male
testparm 		male 		i.F12experiment`c'Recode
estadd scalar p_value = r(p)

reg 			education	i.F12experiment`c'Recode
est sto 	E`c'_education
testparm 		education 	i.F12experiment`c'Recode
estadd scalar p_value = r(p)
} 

esttab * using Tables/TabB7.rtf, se(%9.2f) b(%9.2f) scalar(F p_value) /// 
	nobase label replace  


* Table B7a-c Sample Balance across treatment groups, by country sample

foreach b in  BR DE US {
clear
use PeerOpinionData.dta
decode qCountry, generate(sCountry)
eststo clear
estimates drop _all
keep if sCountry=="`b'"
tab sCountry
	
foreach c in  1 2 3 {
	
reg 			age 		i.F12experiment`c'Recode
est sto 	E`c'_age
testparm 		age 		i.F12experiment`c'Recode
estadd scalar p_value = r(p)

reg 			male		i.F12experiment`c'Recode
est sto 	E`c'_male
testparm 		male 		i.F12experiment`c'Recode
estadd scalar p_value = r(p)

reg 			education	i.F12experiment`c'Recode
est sto 	E`c'_education
testparm 		education 	i.F12experiment`c'Recode
estadd scalar p_value = r(p)
} 

esttab * using Tables/TabB7_`b'.rtf, se(%9.2f) b(%9.2f) scalar(F p_value) /// 
	nobase label replace  

} 



* Table B8 Manipulation checks 

clear
use PeerOpinionData.dta

asdoc tab mcheck1 Country, col nof save(Tables/TabB8_WHO.rtf) replace 
asdoc tab mcheck2 Country, col nof save(Tables/TabB8_IMF.rtf) replace  
asdoc tab mcheck3 Country, col nof save(Tables/TabB8_UN.rtf) replace  


********************************************************************************
******************************* DONE :) ****************************************
********************************************************************************



